package com.bigflexlib.x.mx.states
{
	import mx.core.UIComponent;
	import mx.states.State;

	public class StateUtil
	{
		public static function rotate( target:UIComponent, includeNull:Boolean=false ):void
		{
			var names:Array = target.states.map( function(state:State, index:int, array:Array):String{return state.name} );
			if ( includeNull )
				names.push( null );
			try {
				target.currentState = names[ names.indexOf( target.currentState ) + 1 ];	
			} catch ( e:Error ){
				if ( names.length>0 )
					target.currentState = names[0];
			}

		}
	}
}